﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Orion.MyLib;

namespace Orion.Models
{
	[HandleError]
    public class EmailListController : Controller
    {
		EmailListRepository m_emailListRep = new EmailListRepository( );


        public ActionResult AddEmailList( )
        {
            return View( );
        }

		[HttpPost]
		public ActionResult AddEmailList ( EmailList emaillist )
		{
			try
			{
				//validation
				if (!ModelState.IsValid)
				{
					return View( emaillist );
				}

				m_emailListRep.AddEmailToList(emaillist);

				return RedirectToAction( "Index", "Home" );
			}
			catch ( Exception ex )
			{
				var log = new Logger( );
				log.LogExcepion( ex );
				return View( "Error" );
			}
			
		}
    }
}
